package com.ten.jinxiancun.controller;

import com.ten.jinxiancun.server.impl.PurchasingplanServerImpl;
import com.ten.jinxiancun.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/Pur")
public class PurchasingplanController {

    @Autowired
    PurchasingplanServerImpl pur;
    @RequestMapping("/getAllPur")
    public Object getAllPur(@RequestParam Map<String,Object>map){
        Integer page= Integer.parseInt(map.get("page").toString());
        Integer limit=Integer.parseInt(map.get("limit").toString());
        map.put("page",(page-1)*limit);
        map.put("limit",limit);

        Result res=new Result("0","true",pur.count(map),pur.getAllPur(map));
        return res;
    }

    /*管理员审核 采购计划表 控制器*/
    @RequestMapping("/getAdminPurt")
    public Object getAdminPurt(@RequestParam Map<String,Object>map){
        Integer page= Integer.parseInt(map.get("page").toString());
        Integer limit=Integer.parseInt(map.get("limit").toString());
        map.put("page",(page-1)*limit);
        map.put("limit",limit);

        Result res=new Result("0","true",pur.adminCountFind(map),pur.adminPurchasingplanAllFind(map));
        return res;
    }
    /*管理员审核*/
    @RequestMapping("/adminUpdateSta")
    public  Object adminUpdateSta(@RequestParam Map<String,Object> map){
        int i=pur.adminUpdateInspectorStatusFind(map);
        Result res=new Result("0","true",i,true);
        return res;
    }
    /*管理员审核成功后采购计划胶入采购R入库表的控制器*/
    @RequestMapping("/AddPurDetailsFind")
    public  Object   AddPurDetailsFind(@RequestParam Map<String,Object> map){
        System.out.println("AddPurDetailsFind=================>"+map);
        int  i= pur.AddPurDetailsFind(map);
        Result res=new Result("0","true",i,true);
        return res;
    }
}
